<?php
$host="db.seng.uvic.ca"; // Host name
$username="se321g01"; // Mysql username
$password="un8bi2YM"; // Mysql password
$db_name="se321g01"; // Database name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$target_path = "/home/se321g01/.www/prototype/admin/uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
	// Insert into user_stats
	$link = $_POST['thelink'];
	$fileloc = "http://www.ece.uvic.ca/~se321g01/prototype/admin/uploads/" . basename( $_FILES['uploadedfile']['name']);
	mysql_query("INSERT INTO ads_info (link, file) VALUES
	('$link', '$fileloc')")or die("aww crap");
	
	header("location:./profile.php?uid=" . $uid . "&tab=4");
} else{
    echo "There was an error uploading the file, please try again!";
}

?>